<?php

function member_restaurants_offers_page($rid){
        $header = array(
        array('data' => 'Ajánlat időpontja', 'field' => 'startdate'),            
	array('data' => 'Ajánlat', 'field' => 'offer', 'sort' => 'asc'),
	array('data' => 'Ár(Ft)', 'field' => 'price'),

	);
        
        $query = db_select('ep_offers', 'o');
        $query
                ->fields('o',array('offer','startdate','oid','price','rid'))
                ->extend('TableSort')
                    ->orderByHeader($header);
        $query -> condition('o.rid',$rid,'=');
        
        $results = $query
			->execute();
        $rows = array();	
        foreach ($results as $favourite) {
	$rows[] = array(
				'data' => array(
                                          $favourite->startdate,
					  '<a href="'.url('member/offer_info/'.$favourite->oid).'">'.$favourite->offer.'</a>'.member_add_offer_to_favourite_control($favourite->oid),
                                          $favourite->price,

				)
        );
        }
        $html = theme('table', 
			array(
				'header' => $header,
				'rows'=>$rows,
				'sticky' => TRUE,		
				'empty' => t('Nincs elem ebben a listában...'),
			)
		);

        return  $html;
}